/* eslint-disable no-unused-vars */
import { append as svgAppend, create as svgCreate, classes as svgClasses } from 'tiny-svg';

import { TASK_BORDER_RADIUS } from '../config';
import { drawRect, prependTo } from './utility';
import plusImg from '@/assets/img/plus.svg';

const nodeConfig = {
	url: plusImg,
	x: 0,
	y: 0,
	width: 120,
	height: 80,
	rectColor: '#888888'
};

const name = 'BlankNode';
const drawShape = function(parentNode, element) {
	const rect = drawRect(parentNode, nodeConfig.width, nodeConfig.height, TASK_BORDER_RADIUS, nodeConfig.rectColor);
	// 设置虚线外框
	svgClasses(rect).add('djs-crosshair');

	element['width'] = nodeConfig.width;
	element['height'] = nodeConfig.height;

	prependTo(rect, parentNode);

	// add plus icon
	const plusIcon = svgCreate('image', {
		x: nodeConfig.width / 2 - 15,
		y: nodeConfig.height / 2 - 15,
		width: '30px',
		height: '30px',
		href: nodeConfig.url
	});

	svgAppend(parentNode, plusIcon);

	return rect;
};

export default {
	drawShape,
	name: name
};
